import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:flutter/cupertino.dart';
import 'package:wheel_picker/wheel_picker.dart';



// import 'package:charts_flutter/flutter.dart' as charts;

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _currentIndex = 0;

  final List<String> _titles = [
    '任务管理',
    '数据统计',
    '日历计划',
    '用户管理',
    '番茄时钟',
  ];

  final List<Widget> _pages = [
    TaskPage(),
    DataPage(),
    CalendarPage(),
    ProfilePage(),
    FocusPage(),
  ];

  void _onItemTapped(int index) {
    setState(() {
      _currentIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(_titles[_currentIndex]),
      ),
      body: _pages[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        onTap: _onItemTapped,
        backgroundColor: Colors.blueGrey,
        selectedItemColor: Colors.white,
        unselectedItemColor: Colors.grey[400],
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.check_circle),
            label: '任务管理',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.insert_chart),
            label: '数据统计',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.calendar_today),
            label: '日历计划',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.account_circle),
            label: '用户管理',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.timer),
            label: '番茄时钟',
          ),
        ],
      ),
    );
  }
}

class TaskPage extends StatelessWidget {
  void _showPunchDialog(BuildContext context) {
    final now = TimeOfDay.now();
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('打卡成功'),
          content: Text('打卡时间：${now.format(context)}'),
          actions: [
            TextButton(
              child: Text('确定'),
              onPressed: () => Navigator.of(context).pop(),
            ),
          ],
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // 顶部标题和按钮行
        Padding(
          padding: const EdgeInsets.all(8.0),
          child: Container(
            width: double.infinity,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [

                    Text(
                      '任务管理',
                      style: TextStyle(
                        fontSize: 18,
                        fontWeight: FontWeight.bold,
                        color: Colors.black,
                      ),
                    ),
                    IconButton(
                      icon: Icon(Icons.access_time), // 打卡图标
                      onPressed: () {
                        _showPunchDialog(context);
                      },
                    ),
                  ],
                ),
                Row(
                  children: [

                    IconButton(
                      icon: Icon(Icons.add),
                      onPressed: () {
                        _showAddTaskDialog(context);
                      },
                    ),

                    IconButton(
                      icon: Icon(Icons.folder_open),
                      onPressed: () {
                        // 添加文件夹操作
                      },
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
        // 任务列表
        Expanded(
          child: ListView.builder(
            itemCount: 3,
            itemBuilder: (context, index) {
              return ListTile(
                title: Text('任务 ${index + 1}'),
                subtitle: Text('任务描述'),
                leading: Icon(Icons.check_circle),
                trailing: Icon(Icons.more_vert),
                onTap: () {
                  // 任务详情页
                },
              );
            },
          ),
        ),
      ],
    );
  }
}
void _showAddTaskDialog(BuildContext context) {
  final TextEditingController _taskNameController = TextEditingController();
  final List<Color> _colors = [Colors.brown, Colors.green, Colors.cyan, Colors.pink, Colors.purple];
  Color _selectedColor = _colors[0];
  String _selectedType = '普通';
  double _focusDuration = 25;
  DateTime? _selectedDate;
  int _targetMinutes = 50;
  String _habitUnit = '天';
  int _habitCount = 3;
  int _habitMinutes = 30;
  int _habitEveryValue = 1;
  String _habitEveryUnit = '天';
  final List<String> _habitEveryUnits = ['天', '周', '月', '年'];

  int _habitDurationValue = 24; // 表示25分钟
  String _habitDurationUnit = '分钟';
  final List<String> _habitDurationUnits = ['分钟', '小时', '次'];

  int _targetValue = 49; // 表示50
  String _targetUnit = '分钟';
  final List<String> _targetUnits = ['分钟', '小时', '次'];



  showDialog(
    context: context,
    builder: (BuildContext context) {
      return StatefulBuilder(

        builder: (context, setState) {
          return AlertDialog(
            shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
            contentPadding: EdgeInsets.all(12),
            title: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text('输入任务名', style: TextStyle(fontWeight: FontWeight.bold)),
                IconButton(
                  icon: Icon(Icons.close),
                  onPressed: () => Navigator.of(context).pop(),
                ),
              ],
            ),
            content: SingleChildScrollView(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  // 输入框
                  TextField(
                    controller: _taskNameController,
                    decoration: InputDecoration(hintText: '输入任务名'),
                  ),
                  SizedBox(height: 10),

                  // 颜色选择器
                  Row(
                    children: [
                      ..._colors.map((color) {
                        return GestureDetector(
                          onTap: () => setState(() => _selectedColor = color),
                          child: Container(
                            margin: EdgeInsets.symmetric(horizontal: 4),
                            width: 24,
                            height: 24,
                            decoration: BoxDecoration(
                              color: color,
                              shape: BoxShape.circle,
                              border: Border.all(
                                width: 2,
                                color: _selectedColor == color ? Colors.black : Colors.transparent,
                              ),
                            ),
                          ),
                        );
                      }),
                      GestureDetector(
                        onTap: () async {
                          Color pickedColor = _selectedColor;
                          await showDialog(
                            context: context,
                            builder: (context) {
                              return AlertDialog(
                                title: Text('选择自定义颜色'),
                                content: SingleChildScrollView(
                                  child: ColorPicker(
                                    pickerColor: pickedColor,
                                    onColorChanged: (color) {
                                      pickedColor = color;
                                    },
                                    enableAlpha: false,
                                    labelTypes: const [],
                                    pickerAreaHeightPercent: 0.6,
                                  ),
                                ),
                                actions: [
                                  TextButton(
                                    child: Text('取消'),
                                    onPressed: () => Navigator.of(context).pop(),
                                  ),
                                  ElevatedButton(
                                    child: Text('确定'),
                                    onPressed: () {
                                      setState(() {
                                        _colors.add(pickedColor);
                                        _selectedColor = pickedColor;
                                      });
                                      Navigator.of(context).pop();
                                    },
                                  ),
                                ],
                              );
                            },
                          );
                        },
                        child: Container(
                          margin: EdgeInsets.symmetric(horizontal: 4),
                          width: 24,
                          height: 24,
                          decoration: BoxDecoration(
                            shape: BoxShape.circle,
                            color: Colors.white,
                            border: Border.all(color: Colors.grey),
                          ),
                          child: Icon(Icons.add, size: 18),
                        ),
                      ),
                    ],
                  ),

                  SizedBox(height: 10),

                  // 类型选择
                  Row(
                    children: ['普通', '习惯', '目标'].map((type) {
                      return Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 4.0),
                        child: ChoiceChip(
                          label: Text(type),
                          selected: _selectedType == type,
                          onSelected: (_) => setState(() => _selectedType = type),
                        ),
                      );
                    }).toList(),
                  ),
                  SizedBox(height: 10),

                  // 时长选择
                  Row(
                    children: [
                      Icon(Icons.timer),
                      SizedBox(width: 8),
                      Expanded(
                        child: Slider(
                          value: _focusDuration,
                          min: 0,
                          max: 100,
                          divisions: 20,
                          label: '${_focusDuration.toInt()} 分钟',
                          onChanged: (val) => setState(() => _focusDuration = val),
                        ),
                      ),
                    ],
                  ),
                  SizedBox(height: 6),
                  Center(child: Text('专注时长：${_focusDuration.toInt()} 分钟')),

                  // ========= 【习惯】类型专属区域 =========
                  if (_selectedType == '习惯') ...[
                    Divider(),
                    Text('我想每：'),
                    Row(
                      children: [
                        Expanded(
                          child: TextField(
                            keyboardType: TextInputType.number,
                            decoration: InputDecoration(hintText: ''),
                            onChanged: (val) {
                              _habitEveryValue = int.tryParse(val) ?? 1;
                            },
                          ),
                        ),
                        SizedBox(width: 10),
                        Expanded(
                          child: GestureDetector(
                            onTap: () {
                              setState(() {
                                final index = _habitEveryUnits.indexOf(_habitEveryUnit);
                                _habitEveryUnit = _habitEveryUnits[(index + 1) % _habitEveryUnits.length];
                              });
                            },
                            child: Container(
                              padding: EdgeInsets.symmetric(vertical: 12),
                              decoration: BoxDecoration(
                                border: Border.all(color: Colors.grey),
                                borderRadius: BorderRadius.circular(6),
                              ),
                              alignment: Alignment.center,
                              child: Text('$_habitEveryUnit', style: TextStyle(fontSize: 16)),
                            ),
                          ),
                        ),
                      ],
                    ),
                    SizedBox(height: 16),
                    Text('每次参与时间'),
                    Row(
                      children: [
                        // 数字选择（拨轮 + 长按输入）
                        Expanded(
                          child: GestureDetector(
                            onLongPress: () async {
                              final input = await showDialog<String>(
                                context: context,
                                builder: (context) {
                                  final controller = TextEditingController(text: '${_habitDurationValue + 1}');
                                  return AlertDialog(
                                    title: Text('自定义数字'),
                                    content: TextField(
                                      controller: controller,
                                      keyboardType: TextInputType.number,
                                      decoration: InputDecoration(hintText: '输入数值'),
                                    ),
                                    actions: [
                                      TextButton(
                                        onPressed: () => Navigator.pop(context),
                                        child: Text('取消'),
                                      ),
                                      ElevatedButton(
                                        onPressed: () => Navigator.pop(context, controller.text),
                                        child: Text('确定'),
                                      ),
                                    ],
                                  );
                                },
                              );
                              if (input != null) {
                                final val = int.tryParse(input);
                                if (val != null && val > 0) {
                                  setState(() {
                                    _habitDurationValue = val - 1;
                                  });
                                }
                              }
                            },
                            child: Container(
                              height: 100,
                              child: CupertinoPicker(
                                scrollController: FixedExtentScrollController(initialItem: _habitDurationValue),
                                itemExtent: 36,
                                onSelectedItemChanged: (i) => setState(() => _habitDurationValue = i),
                                children: List.generate(60, (i) => Center(child: Text('${i + 1}'))),
                              ),
                            ),
                          ),
                        ),

                        // 单位切换 + 动画切换
                        Expanded(
                          child: GestureDetector(
                            onTap: () {
                              setState(() {
                                final index = _habitDurationUnits.indexOf(_habitDurationUnit);
                                _habitDurationUnit = _habitDurationUnits[(index + 1) % _habitDurationUnits.length];
                              });
                            },
                            child: Container(
                              padding: EdgeInsets.symmetric(vertical: 12),
                              decoration: BoxDecoration(
                                border: Border.all(color: Colors.grey),
                                borderRadius: BorderRadius.circular(6),
                              ),
                              alignment: Alignment.center,
                              child: AnimatedSwitcher(
                                duration: Duration(milliseconds: 300),
                                transitionBuilder: (child, animation) => SlideTransition(
                                  position: Tween<Offset>(
                                    begin: Offset(0.0, 1.0),
                                    end: Offset.zero,
                                  ).animate(animation),
                                  child: FadeTransition(opacity: animation, child: child),
                                ),
                                child: Text(
                                  _habitDurationUnit,
                                  key: ValueKey(_habitDurationUnit),
                                  style: TextStyle(fontSize: 16),
                                ),
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),

                  ],

                  // ========= 【目标】类型专属区域 =========
                  if (_selectedType == '目标') ...[
                    Divider(),
                    Text('选择截止日期'),
                    TextButton(
                      onPressed: () async {
                        final date = await showDatePicker(
                          context: context,
                          initialDate: DateTime.now(),
                          firstDate: DateTime(2020),
                          lastDate: DateTime(2100),
                        );
                        if (date != null) setState(() => _selectedDate = date);
                      },
                      child: Text(
                        _selectedDate == null
                            ? '选择日期'
                            : '${_selectedDate!.year}-${_selectedDate!.month}-${_selectedDate!.day}',
                      ),
                    ),
                    SizedBox(height: 10),
                    Text('总目标参与量'),
                    Row(
                      children: [
                        Expanded(
                          child: CupertinoPicker(
                            scrollController: FixedExtentScrollController(initialItem: _targetValue),
                            itemExtent: 36,
                            onSelectedItemChanged: (i) {
                              setState(() {
                                _targetValue = i;
                              });
                            },
                            children: List.generate(100, (i) => Center(child: Text('${i + 1}'))),
                          ),
                        ),
                        Expanded(
                          child: GestureDetector(
                            onTap: () {
                              setState(() {
                                final index = _targetUnits.indexOf(_targetUnit);
                                _targetUnit = _targetUnits[(index + 1) % _targetUnits.length];
                              });
                            },
                            child: Container(
                              padding: EdgeInsets.symmetric(vertical: 12),
                              decoration: BoxDecoration(
                                border: Border.all(color: Colors.grey),
                                borderRadius: BorderRadius.circular(6),
                              ),
                              alignment: Alignment.center,
                              child: Text('$_targetUnit', style: TextStyle(fontSize: 16)),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ],

                  SizedBox(height: 20),
                  Center(
                    child: ElevatedButton(
                      onPressed: () {
                        // 保存任务逻辑
                        Navigator.of(context).pop();
                      },
                      child: Text('保存'),
                    ),
                  )
                ],
              ),
            ),

          );
        },
      );

    },
  );
}


class DataPage extends StatefulWidget {
  @override
  _DataPageState createState() => _DataPageState();
}

class _DataPageState extends State<DataPage> {
  // 用来控制折叠的状态
  bool _isHistoryDataExpanded = true;
  bool _isCumulativeExpanded = true;
  bool _isTodayExpanded = true;
  bool _isAverageExpanded = true;

  bool _isTimeDistributionExpanded = true;
  bool _isBarChartExpanded = true;
  bool _isPieChartExpanded = true;
  bool _isTrendChartExpanded = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: ListView(
          children: [
            // 统计数据标题栏
            // 历史专注数据栏
            _buildCollapsibleSection(
              '历史专注',
              _isHistoryDataExpanded,
                  () {
                setState(() {
                  _isHistoryDataExpanded = !_isHistoryDataExpanded;
                });
              },
              _isHistoryDataExpanded
                  ? Column(
                children: [
                  _buildCategory('累计', _isCumulativeExpanded),
                  _buildCategory('当日', _isTodayExpanded),
                  _buildCategory('平均', _isAverageExpanded),
                ],
              )
                  : null,
            ),

            // 时间分布图
            _buildCollapsibleSection(
              '时间分布图',
              _isTimeDistributionExpanded,
                  () {
                setState(() {
                  _isTimeDistributionExpanded = !_isTimeDistributionExpanded;
                });
              },
              _isTimeDistributionExpanded
                  ? Column(
                children: [
                  _buildChartCategory('柱状图', _isBarChartExpanded, _buildBarChart()),
                  _buildChartCategory('饼状图', _isPieChartExpanded, _buildPieChart()),
                  _buildChartCategory('趋势图', _isTrendChartExpanded, _buildTrendChart()),
                ],
              )
                  : null,
            ),
          ],
        ),
      ),
    );
  }

  // 可折叠模块（带下划线）
  Widget _buildCollapsibleSection(
      String title,
      bool isExpanded,
      Function onTap,
      Widget? child,
      ) {
    return GestureDetector(
      onTap: () => onTap(),
      child: Container(
        margin: EdgeInsets.symmetric(vertical: 8),
        padding: EdgeInsets.symmetric(vertical: 8),
        decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(
              color: Colors.black,
              width: 1,
            ),
          ),
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Icon(
                  isExpanded
                      ? Icons.arrow_drop_up
                      : Icons.arrow_drop_down,
                  color: Colors.black,
                ),
                Text(
                  title,
                  style: TextStyle(
                    fontSize: 18,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
            if (isExpanded && child != null) child,
          ],
        ),
      ),
    );
  }

  // 构建分类（历史专注）
  Widget _buildCategory(String category, bool isExpanded) {
    return GestureDetector(
      onTap: () {
        setState(() {
          if (category == '累计') {
            _isCumulativeExpanded = !_isCumulativeExpanded;
          } else if (category == '当日') {
            _isTodayExpanded = !_isTodayExpanded;
          } else if (category == '平均') {
            _isAverageExpanded = !_isAverageExpanded;
          }
        });
      },
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 16),
        child: Column(
          children: [
            Row(
              children: [
                Icon(
                  isExpanded
                      ? Icons.arrow_drop_up
                      : Icons.arrow_drop_down,
                  color: Colors.black,
                ),
                Text(
                  category,
                  style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ],
            ),
            if (isExpanded) _buildStats(),
          ],
        ),
      ),
    );
  }

  // 构建统计数据
  Widget _buildStats() {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 24.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          _buildStatItem('次数', '50'),
          _buildStatItem('时长', '3小时'),
          _buildStatItem('天数', '30天'),
        ],
      ),
    );
  }

  // 构建每一项数据
  Widget _buildStatItem(String label, String value) {
    return Column(
      children: [
        Text(
          label,
          style: TextStyle(fontSize: 14, color: Colors.grey),
        ),
        Text(
          value,
          style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
        ),
      ],
    );
  }

  // 构建图表分类
  Widget _buildChartCategory(String category, bool isExpanded, Widget chart) {
    return GestureDetector(
      onTap: () {
        setState(() {
          if (category == '柱状图') {
            _isBarChartExpanded = !_isBarChartExpanded;
          } else if (category == '饼状图') {
            _isPieChartExpanded = !_isPieChartExpanded;
          } else if (category == '趋势图') {
            _isTrendChartExpanded = !_isTrendChartExpanded;
          }
        });
      },
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 16),
        child: Column(
          children: [
            Row(
              children: [
                Icon(
                  isExpanded
                      ? Icons.arrow_drop_up
                      : Icons.arrow_drop_down,
                  color: Colors.black,
                ),
                Text(
                  category,
                  style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ],
            ),
            if (isExpanded) chart,
          ],
        ),
      ),
    );
  }

  // 模拟柱状图
  Widget _buildBarChart() {
    return Container(
      height: 200,
      margin: EdgeInsets.symmetric(vertical: 8),
      color: Colors.blue[100],
      child: Center(child: Text('柱状图', style: TextStyle(fontSize: 20))),
    );
  }

  // 模拟饼状图
  Widget _buildPieChart() {
    return Container(
      height: 200,
      margin: EdgeInsets.symmetric(vertical: 8),
      color: Colors.green[100],
      child: Center(child: Text('饼状图', style: TextStyle(fontSize: 20))),
    );
  }

  // 模拟趋势图
  Widget _buildTrendChart() {
    return Container(
      height: 200,
      margin: EdgeInsets.symmetric(vertical: 8),
      color: Colors.orange[100],
      child: Center(child: Text('趋势图', style: TextStyle(fontSize: 20))),
    );
  }
}

class CalendarPage extends StatelessWidget {
  // 构建日期行（横向）
  Widget buildDateRow() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: List.generate(7, (index) {
        return Text(
          'Day ${index + 1}', // 显示星期几或日期
          style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
        );
      }),
    );
  }

  // 构建每一天的任务块（任务色块）
  Widget buildTaskBlock(String taskName, Color taskColor) {
    return Container(
      margin: EdgeInsets.all(4),
      padding: EdgeInsets.all(8),
      color: taskColor,
      child: Center(
        child: Text(taskName, style: TextStyle(color: Colors.white)),
      ),
    );
  }

  // 构建计划模块
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          // 日期行（横向）
          buildDateRow(),
          SizedBox(height: 10),
          Expanded(
            child: ListView.builder(
              itemCount: 24, // 每小时一个条目（0-23小时）
              itemBuilder: (context, hour) {
                return Padding(
                  padding: const EdgeInsets.symmetric(vertical: 4),
                  child: Row(
                    children: [
                      // 时间轴：显示0-23小时
                      Container(
                        width: 50,
                        padding: EdgeInsets.symmetric(vertical: 10),
                        child: Text(
                          '$hour:00', // 显示每小时的时间
                          style: TextStyle(fontSize: 14),
                        ),
                      ),
                      // 任务块：显示计划和实际任务
                      Expanded(
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.start,
                          children: List.generate(7, (index) {
                            return Expanded(
                              child: buildTaskBlock(
                                '计划任务 $hour', // 计划任务的名称
                                index.isEven ? Colors.lightBlue : Colors.greenAccent, // 偶数用蓝色，奇数用绿色
                              ),
                            );
                          }),
                        ),
                      ),
                    ],
                  ),
                );
              },
            ),
          ),
        ],
      ),
    );
  }
}

class ProfilePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // 用户模块 - 个人信息卡片
        Container(
          width: 360,
          height: 76,
          padding: EdgeInsets.all(10),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(8),
            boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 6)],
          ),
          child: Row(
            children: [
              // 使用 CircleAvatar 替代头像，背景为灰色，占位图标为人物
              CircleAvatar(
                radius: 30, // 设置头像半径
                backgroundColor: Colors.grey, // 设置灰色背景
                child: Icon(
                  Icons.person, // 人物图标
                  color: Colors.white, // 图标颜色
                  size: 40, // 图标大小
                ),
              ),
              SizedBox(width: 10),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      '昵称: 小明',
                      style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
                    ),
                    Text(
                      '励志语句：每天进步一点点',
                      style: TextStyle(fontSize: 12, color: Colors.grey),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
        // 用户ID不可修改
        Container(
          margin: EdgeInsets.all(10),
          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
          color: Colors.grey[200],
          child: Row(
            children: [
              Text(
                'ID: 123456789',
                style: TextStyle(fontSize: 16, color: Colors.grey),
              ),
            ],
          ),
        ),
        // 手机号输入框（可修改）
        Container(
          margin: EdgeInsets.all(10),
          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(8),
          ),
          child: TextField(
            decoration: InputDecoration(
              labelText: '手机号',
              border: InputBorder.none,
            ),
          ),
        ),
        // 密码输入框（可修改）
        Container(
          margin: EdgeInsets.all(10),
          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(8),
          ),
          child: TextField(
            decoration: InputDecoration(
              labelText: '密码',
              border: InputBorder.none,
            ),
            obscureText: true,
          ),
        ),
        // 退出按钮
        Padding(
          padding: const EdgeInsets.all(20.0),
          child: ElevatedButton(
            onPressed: () {
              // 退出登录操作
            },
            style: ElevatedButton.styleFrom(
              backgroundColor: Colors.red, // 使用 backgroundColor 替代 primary
              padding: EdgeInsets.symmetric(vertical: 10),
              minimumSize: Size(104, 37),
            ),
            child: Text(
              '退出',
              style: TextStyle(fontSize: 16),
            ),
          ),
        ),
      ],
    );
  }
}
class FocusPage extends StatefulWidget {
  @override
  _FocusPageState createState() => _FocusPageState();
}

class _FocusPageState extends State<FocusPage> {
  String currentTime = "01:11"; // 当前时刻
  String taskName = "习惯-每天完成10min"; // 当前任务名
  String taskDetails = "类型：10分钟专注"; // 任务详情

  // 控制时钟和任务
  void startTimer() {
    // 开始计时的逻辑，可以使用 Timer 来实现
    setState(() {
      currentTime = "01:12"; // 这里只是示例，实际可通过计时器更新
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView( // 添加可滚动的容器
        padding: EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            // 励志语句
            Container(
              width: 345,
              height: 102,
              padding: EdgeInsets.fromLTRB(6, 4, 8, 4),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(21),
                color: Colors.grey[200],
              ),
              child: Text(
                '要有最朴素的生活和最遥远的梦想，即使明天天寒地冻，山高水远，路远马亡。 —— 《枫》',
                style: TextStyle(
                  fontSize: 20,
                  fontFamily: "思源黑体 Medium",
                  color: Color(0xD9000000),
                  height: 1.4,
                ),
                textAlign: TextAlign.center,  // 确保文本居中
              ),
            ),
            SizedBox(height: 20),
            // 时钟显示
            Center(
              child: Container(
                width: 280,
                height: 167,
                padding: EdgeInsets.all(2),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(34),
                  color: Colors.black.withOpacity(0.13),
                  border: Border.all(
                    color: Colors.black.withOpacity(0.54),
                    width: 10,
                  ),
                ),
                child: Center(
                  child: Text(
                    currentTime, // 显示当前时刻
                    style: TextStyle(
                      fontFamily: "Algerian",
                      fontSize: 60,
                      color: Color(0xFF333333),
                    ),
                  ),
                ),
              ),
            ),
            SizedBox(height: 20),
            // 当前任务
            Container(
              width: 170,
              height: 46,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5),
                color: Colors.transparent,
                border: Border.all(color: Colors.black.withOpacity(0.2)),
              ),
              child: Center(
                child: Text(
                  taskName, // 当前任务名称
                  style: TextStyle(
                    fontFamily: "华文中宋",
                    fontSize: 16,
                    color: Color(0xFF333333),
                  ),
                  textAlign: TextAlign.center, // 任务名称居中
                ),
              ),
            ),
            SizedBox(height: 10),
            // 任务详情
            Container(
              width: 188,
              height: 26,
              padding: EdgeInsets.all(4),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(9),
                color: Color(0xF9E0F2).withOpacity(0.49),
                border: Border.all(color: Color(0xDCACCFF)),
              ),
              child: Center(
                child: Text(
                  taskDetails, // 任务详情（例如10分钟专注）
                  style: TextStyle(
                    fontFamily: "楷体",
                    fontSize: 14,
                    color: Color(0x676767),
                  ),
                  textAlign: TextAlign.center, // 任务详情居中
                ),
              ),
            ),
            SizedBox(height: 30),
            // 控制按钮区域
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                // 常亮按钮
                IconButton(
                  icon: Icon(Icons.brightness_7),
                  iconSize: 30,
                  onPressed: () {
                    // 常亮按钮的功能
                  },
                ),
                // 音乐按钮
                IconButton(
                  icon: Icon(Icons.music_note),
                  iconSize: 30,
                  onPressed: () {
                    // 音乐按钮的功能
                  },
                ),
                // 结束按钮
                IconButton(
                  icon: Icon(Icons.stop),
                  iconSize: 40,
                  color: Colors.red,
                  onPressed: () {
                    // 结束按钮的功能
                  },
                ),
                // 暂停按钮
                IconButton(
                  icon: Icon(Icons.pause),
                  iconSize: 30,
                  onPressed: () {
                    // 暂停按钮的功能
                  },
                ),
                // 重置按钮
                IconButton(
                  icon: Icon(Icons.refresh),
                  iconSize: 30,
                  onPressed: () {
                    // 重置按钮的功能
                  },
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}